package cn.itcast.demo.controller;

import cn.itcast.demo.interceptors.MarketIntercptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Autowired
    private MarketIntercptor marketIntercptor;


    //拦截器在定义时候，可以指定匹配路径，（指定资源拦截）
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(marketIntercptor).addPathPatterns("/user/**");
    }
}
